package P01_thread;

import org.junit.jupiter.api.Test;

public class P1 {
    @Test
    public void test01() {
        Thread aa = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "::" + Thread.currentThread().isDaemon());
            int i = 0;
            while (true) {
                System.out.print(i + ", ");
                i++;
            }
        }, "aa");
        aa.start();
        System.out.println(Thread.currentThread().getName() + " over.");
    }

    public static void main(String[] args) {
        Thread aa = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "::" + Thread.currentThread().isDaemon());
            int i = 0;
            while (true) {
                System.out.print(i + ", ");
                i++;
            }
        }, "aa");
        // 设置守护线程
        aa.setDaemon(true);
        aa.start();
        System.out.println(Thread.currentThread().getName() + " over.");
    }
}
